package com.bsoft.gol.hcs.followup.controller;

import ctd.mvc.controller.OutputSupportMVCController;

/**
 * 院后随访相关控制器
 *
 * @author neoLin - 2022/07/19 09:58
 **/
//@Controller
//@RequestMapping("/api/auth/afterHosRecord/")
//@Slf4j
public class FusAfterHosRecordController extends OutputSupportMVCController{
//
//    @Resource
//    private HospitalDischargeFollowUpService hospitalDischargeFollowUpService;
//
//    @Autowired
//    private HttpServletResponse httpServletResponse;
//
//    /**
//     * 随访人员工作量统计导出
//     */
//    @PostMapping(value = "doctorFusExport")
//    public void doctorFusExport(FollowUpSatDocDTO dto) throws IOException {
//        List<FollowUpSatDocVO> dataList = hospitalDischargeFollowUpService.doctorFusStatisticsExport(dto);
//        ByteArrayOutputStream bos = new ByteArrayOutputStream();
//        EasyExcel.write(bos, FollowUpSatDocVO.class).sheet("导出数据").doWrite(dataList);
//        String fileName = "随访人员工作量统计.xlsx";
//        export(fileName, bos);
//    }
//
//    /**
//     * 路径随访工作量统计导出
//     */
//    @PostMapping(value = "routeFusExport")
//    public void routeFusExport(FollowUpSatDTO dto) throws IOException {
//        List<FollowUpSatVO> dataList = hospitalDischargeFollowUpService.routeFusStatisticsExport(dto);
//        ByteArrayOutputStream bos = new ByteArrayOutputStream();
//        Set<String> excludeColumnFiledNames = new HashSet<>();
//        excludeColumnFiledNames.add("departmentName");
//        EasyExcel.write(bos, FollowUpSatVO.class).excludeColumnFiledNames(excludeColumnFiledNames).sheet("导出数据").doWrite(dataList);
//        String fileName = "路径随访工作量统计.xlsx";
//        export(fileName, bos);
//    }
//
//    /**
//     * 科室随访工作量统计导出
//     */
//    @PostMapping(value = "deptFusExport")
//    public void deptFusExport(FollowUpSatDTO dto) throws IOException {
//        List<FollowUpSatVO> dataList = hospitalDischargeFollowUpService.deptFusStatisticsExport(dto);
//        ByteArrayOutputStream bos = new ByteArrayOutputStream();
//        Set<String> excludeColumnFiledNames = new HashSet<>();
//        excludeColumnFiledNames.add("routeName");
//        EasyExcel.write(bos, FollowUpSatVO.class).excludeColumnFiledNames(excludeColumnFiledNames).sheet("导出数据").doWrite(dataList);
//        String fileName = "科室随访工作量统计.xlsx";
//        export(fileName, bos);
//    }
//
//    private void export(String fileName, ByteArrayOutputStream bos) throws IOException {
//        ServletOutputStream outputStream = null;
//        try {
//            byte[] bytes = bos.toByteArray();
//            int filesize = bytes.length;
//            ByteArrayInputStream bis = new ByteArrayInputStream(bytes);
//            httpServletResponse.setStatus(200);
//            httpServletResponse.setContentType(OutputSupportMVCController.mimeTypeMap.getContentType(fileName));
//            httpServletResponse.setContentLength(filesize);
//            httpServletResponse.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName, "UTF-8"));
//            outputStream = httpServletResponse.getOutputStream();
//            outputStream.write(bos.toByteArray());
//        }catch (Exception e){
//            log.error("导出文件失败", e);
//            JSONResponseBean rtn = new JSONResponseBean();
//            rtn.setCode(500);
//            rtn.setMsg("导出文件失败");
//            jsonOutput(httpServletResponse, rtn, false);
//        }finally {
//            bos.flush();
//            bos.close();
//            if(outputStream != null){
//                outputStream.flush();
//                outputStream.close();
//            }
//        }
//    }


}
